﻿'***********************************************************************
' Assembly         : SOFA.Caching
' Copyright        : (c) Jebarson. All rights reserved.
' Website			: http://www.jebarson.info
'***********************************************************************

Option Strict Off

Namespace Caching.StaticStore

    ''' <summary>
    ''' Storage type for static store.
    ''' </summary>
    ''' <typeparam name="T"></typeparam>
    Friend Class StaticStorage(Of T As StaticStorageConfig)
        Implements ICacheStorage(Of ICacheStorageConfig)

#Region " Declarations "
        ''' <summary>
        ''' Gets a singleton instance for the store.
        ''' </summary>
        Public Shared Instance As New StaticStorage(Of StaticStorageConfig)
#End Region

#Region " Constructors "
        ''' <summary>
        ''' Initializes a new instance of the <see cref="StaticStorage(Of T)" /> class.
        ''' </summary>
        Private Sub New()

            MyBase.New()
        End Sub
#End Region

#Region " ICacheStorage Support "
        ''' <summary>
        ''' Adds the storage item.
        ''' </summary>
        ''' <param name="item">The item.</param>
        Public Sub AddStorageItem(ByVal item As Object) Implements ICacheStorage(Of ICacheStorageConfig).AddStorageItem

            StaticStorageFactory.Instance.AddStorageItem(item)
        End Sub

        ''' <summary>
        ''' Gets the storage item.
        ''' </summary>
        ''' <param name="name">The name.</param>
        ''' <returns>The storage item.</returns>
        Public Function GetStorageItem(ByVal name As String) As Object Implements ICacheStorage(Of ICacheStorageConfig).GetStorageItem

            Return StaticStorageFactory.Instance.GetStorageItem(name)
        End Function

        ''' <summary>
        ''' Gets the name.
        ''' </summary>
        ''' <param name="item">The item.</param>
        ''' <returns>The name of the storage item.</returns>
        Public Function GetName(ByVal item As Object) As String Implements ICacheStorage(Of ICacheStorageConfig).GetName

            Return StaticStorageFactory.Instance.GetName(item)
        End Function
#End Region

#Region " IDisposable Support "
        ''' <summary>
        ''' Member variable for disposing value flag.
        ''' </summary>
        Private disposedValue As Boolean

        ''' <summary>
        ''' Releases unmanaged and - optionally - managed resources
        ''' </summary>
        ''' <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
        Protected Overridable Sub Dispose(ByVal disposing As Boolean)
            If Not Me.disposedValue Then
                If disposing Then

                End If
            End If
            Me.disposedValue = True
        End Sub

        ''' <summary>
        ''' Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
        ''' </summary>
        Public Sub Dispose() Implements IDisposable.Dispose
            Me.Dispose(True)
            GC.SuppressFinalize(Me)
        End Sub
#End Region
    End Class
End Namespace